from pyecharts.charts import Map
from pyecharts.options import TitleOpts,VisualMapOpts

# 获取地图实例对象
map = Map()

# 准备地图中的数据
data = [ ("北京市", 100),
         ("上海市", 238),
         ("湖南", 45),
         ("湖北省", 636),
         ("河南省", 5),
         ("海南省", 0)]

# 配置地图属性
map.add("测试地图", data, "china")

# 设置全局参数
map.set_global_opts(
    title_opts=TitleOpts("新冠每日新增数", pos_left="center", pos_bottom='3%'),
    visualmap_opts=VisualMapOpts(
        is_show=True,
        is_piecewise=True,
        pieces=[
            {"value":0, "label":'0', "color":'#99FF99'},
            {"min":1, "max":10, "label":'1-10', "color":'#CCFF66'},
            {"min":11, "max":100, "label":'11-100', "color":'#FFFF33'},
            {"min":101, "max":500, "label":'101-500', "color":'#FF99CC'},
            {"min":501, "label":'500以上', "color":'#FF3300'}
        ]
    )
)

# 生成地图
map.render()